home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Workbench Add-On
/
Workbench Add-On - Volume 1.iso
/
BBS-Archive
/
Dev
/
ACE_Prgs.lha
/
speech
/
sprecog.lha
/
numrecog.b
next >
Wrap
Text File
|
1995-01-29
|
3KB
|
111 lines
'...speech recognition with voice.library
LIBRARY exec
LIBRARY dos
LIBRARY voice
DECLARE FUNCTION AllocMem& LIBRARY exec
DECLARE FUNCTION FreeMem LIBRARY exec
DECLARE FUNCTION xOpen& LIBRARY dos
DECLARE FUNCTION xClose LIBRARY dos
DECLARE FUNCTION xWrite LIBRARY dos
DECLARE FUNCTION xRead& LIBRARY dos
DECLARE FUNCTION PickSampler LIBRARY voice
DECLARE FUNCTION GainUp LIBRARY voice
DECLARE FUNCTION GainDown LIBRARY voice
DECLARE FUNCTION Learn LIBRARY voice
DECLARE FUNCTION Recognize& LIBRARY voice
LONGINT max_num
'..words to recognise
DIM word$(10)
FOR i%=0 TO 8
READ word$(i%)
NEXT
DATA one,two,three,four,five,six,seven,eight,nine
'..Recognise() errors
DIM rerror$(5)
FOR i%=1 TO 4
READ rerror$(i%)
NEXT
DATA "No match.","Volume too high.","Volume too low.","Confused by noise."
'..Isaac's (my A500) speech characteristics
DIM v%(9)
FOR i%=0 TO 8
READ v%(i%)
NEXT
DATA 80,0,160,0,22900,64,10,0,0
PickSampler(0&) '..Perfect SOUND Sampler
GainUp '..volume up one notch
CLS
PRINT
PRINT "*** Speech Recognition of numbers 1 to";max_num;"***"
PRINT
INPUT "Read voice patterns from (F)ile or (R)e-learn? ",ans$
IF UCASE$(ans$)="F" THEN
'..read stored patterns
INPUT "How many numbers in file: ",max_num
'..allocate memory for words and frequency-time maps
MapBuffer&=AllocMem(CLNG(304*max_num),2&)
INPUT "Enter name of file: ",f$
PRINT "Reading ";f$
fh&=xOpen&(SADD(f$),1005&) '..OPEN FOR reading
xRead(fh&,MapBuffer&,CLNG(304*max_num))
xClose(fh&)
ELSE
'..learn max_num words (numbers 1 to max_num)
INPUT "Specify how many numbers to learn: ",max_num
'..allocate memory for words and frequency-time maps
MapBuffer&=AllocMem(CLNG(304*max_num),2&)
FOR i&=0 TO max_num-1
Learn(MapBuffer&,SADD(word$(i&)),0&,i&,100&,75&)
NEXT
'..store words and maps in file
INPUT "Enter name of file: ",f$
fh&=xOpen&(SADD(f$),1006&) '..OPEN FOR writing
xWrite(fh&,MapBuffer&,CLNG(304*max_num))
xClose(fh&)
END IF
CLS
PRINT
PRINT "*** Speech Recognition of numbers 1 to";max_num;"***"
PRINT
'..resolution?
REPEAT
INPUT "Enter recognition resolution (hi = 0,lo = 1 or -1 to quit): ",res&
UNTIL res&=-1 OR res&=0 OR res&=1
IF res& = -1 THEN cleanup
'..recognise words until left mouse button held down
PRINT
WHILE NOT MOUSE(0)
PRINT "speak number..."
wd%=Recognize(MapBuffer&,max_num,res&)
IF wd%>=0 THEN
PRINT word$(wd%)
SAY TRANSLATE$(word$(wd%)),v%
ELSE
PRINT rerror$(ABS(wd%))
END IF
WEND
cleanup:
FreeMem(MapBuffer&,CLNG(304*max_num))
GainDown '..restore volume setting to that prior to running program
LIBRARY CLOSE voice
LIBRARY CLOSE dos
LIBRARY CLOSE exec